/**************************************************************************
 * @file usr_desplay_task.h
 * @author BryanHe(贺璧) (532352406@qq.com)
 * @brief 
 * @version 0.1
 * @date 2024-02-21
 * 
 * @copyright Copyright (c) 2024
 * 
 *************************************************************************/
#ifndef USR_DESPLAY_TASK__H_H
#define USR_DESPLAY_TASK__H_H
#include<stdint.h>
#include<stdio.h>

#ifdef __cplusplus
extern "C"{
#endif
#include "mo_config.h"
#include "mcu_button.h"
#include "usr_debug.h"
#include "mo_input.h"
#include "mo_msg.h"
#include "usr_app_common_inc.h"
#include "lcd_init.h"
#include "lcd.h"

#define CURR_A " A"
#define CURR_mA "mA"
#define CURR_uA "uA"

#define POWER_W " W"
#define POWER_mW "mW"
#define POWER_uW "uW"

#define TABLE_START_Y 4
#define TABLE_START_X 34
#define ROW_DISTANCE  20
#define ROW_NUMBER    8
#define COLUMN_DES    25
#define COLUMN_NUM    10
#define INPUT_DAT_MAX (COLUMN_DES * COLUMN_NUM)
#define TABLE_HEIGHT  (ROW_DISTANCE * ROW_NUMBER)
#define TABLE_WIDTH   (COLUMN_DES * COLUMN_NUM)

#define OUT_CTRL_BLOCK_POSSITION_X 110
#define OUT_CTRL_BLOCK_POSSITION_Y 3
#define OUT_CTRL_B_WIDTH           86
#define OUT_CTRL_B_HEIGHT          40

#define OUT_CTRL_B_X_END (OUT_CTRL_BLOCK_POSSITION_X+OUT_CTRL_B_WIDTH)
#define OUT_CTRL_B_Y_END (OUT_CTRL_BLOCK_POSSITION_Y+OUT_CTRL_B_HEIGHT)

#if (USR_DBG_PRINT_EN)
#define EN_UPLOAD_DAT_TO_APP 0
#else
#define EN_UPLOAD_DAT_TO_APP 1
#endif

#define BAK1_OUTLINE_COLOR RGB_to_565(49, 86, 83)
#define BAK2_COLOR         RGB_to_565(0, 40, 41)
#define BAK1_COLOR         RGB_to_565(0, 40, 41)
#define BAK_COLOR          RGB_to_565(0, 40, 41)
#define BAK3_COLOR         RGB_to_565(0, 40, 41)
#define BAK4_COLOR         RGB_to_565(0, 40, 41)

/*********************Curve UI 控件坐标位置*************************************** */
#define BAK_CURVE_COLOR             BAK1_COLOR
#define BAK_CURVE_FRONT_COLOR_INPUT RGB_to_565(200, 200, 200)
/**INPUT BLOCK */
#define CURVE_IN_BK_COLOR         BAK_CURVE_COLOR
#define CURVE_IN_FRONT_COLOR      BAK_CURVE_FRONT_COLOR_INPUT
#define CURVE_IN_BLOCK_LINE_COLOR BAK1_OUTLINE_COLOR
#define CURVE_IN_BLOCK_START_Px   6
#define CURVE_IN_BLOCK_START_Py   185
#define CURVE_IN_BLOCK_W          72
#define CURVE_IN_BLOCK_H          50
#define CURVE_IN_ICON_START_Px  (CURVE_IN_BLOCK_START_Px + 4)
#define CURVE_IN_ICON_START_Py  (CURVE_IN_BLOCK_START_Py + 1)
#define CURVE_IN_V_STR_START_Px (CURVE_IN_BLOCK_START_Px + 10)
#define CURVE_IN_V_STR_START_Py (CURVE_IN_BLOCK_START_Py + 14)
#define CURVE_IN_C_STR_START_Px (CURVE_IN_BLOCK_START_Px + 10)
#define CURVE_IN_C_STR_START_Py (CURVE_IN_BLOCK_START_Py + 30)
/******** */
/**Setting BLOCK */
#define CURVE_CFG_BK_COLOR       BAK_CURVE_COLOR
#define CURVE_CFG_FRONT_COLOR    RGB_to_565(120,120,120)
#define CURVE_CFG_BLOCK_START_Px 85
#define CURVE_CFG_BLOCK_START_Py 185
#define CURVE_CFG_BLOCK_W          72
#define CURVE_CFG_BLOCK_H          50
#define CURVE_CFG_ICON_START_Px  (CURVE_CFG_BLOCK_START_Px + 4)
#define CURVE_CFG_ICON_START_Py  (CURVE_CFG_BLOCK_START_Py + 1)
#define CURVE_CFG_V_STR_START_Px (CURVE_CFG_BLOCK_START_Px + 14)
#define CURVE_CFG_V_STR_START_Py (CURVE_CFG_BLOCK_START_Py + 14)
#define CURVE_CFG_C_STR_START_Px (CURVE_CFG_BLOCK_START_Px + 14)
#define CURVE_CFG_C_STR_START_Py (CURVE_CFG_BLOCK_START_Py + 30)
/******** */
/**Out BLOCK */
#define CURVE_OUT_BK_COLOR       BAK_CURVE_COLOR
#define CURVE_OUT_FRONT_COLOR    BAK_CURVE_FRONT_COLOR_INPUT
#define CURVE_OUT_BLOCK_START_Px 164
#define CURVE_OUT_BLOCK_START_Py 185
#define CURVE_OUT_BLOCK_W          72
#define CURVE_OUT_BLOCK_H          50
#define CURVE_OUT_ICON_START_Px  (CURVE_OUT_BLOCK_START_Px + 4)
#define CURVE_OUT_ICON_START_Py  (CURVE_OUT_BLOCK_START_Py + 1)
#define CURVE_OUT_V_STR_START_Px (CURVE_OUT_BLOCK_START_Px + 12)
#define CURVE_OUT_V_STR_START_Py (CURVE_OUT_BLOCK_START_Py + 14)
#define CURVE_OUT_C_STR_START_Px (CURVE_OUT_BLOCK_START_Px + 12)
#define CURVE_OUT_C_STR_START_Py (CURVE_OUT_BLOCK_START_Py + 30)
/******** */
/**State BLOCK */
#define CURVE_STATE_BK_COLOR           BAK_CURVE_COLOR
#define CURVE_STATE_FRONT_COLOR        BAK_CURVE_FRONT_COLOR_INPUT
#define CURVE_STATE_BLOCK_START_Px     243
#define CURVE_STATE_BLOCK_START_Py     185
#define CURVE_STATE_BLOCK_W          72
#define CURVE_STATE_BLOCK_H          50
#define CURVE_STATE_OUT_STR_START_Px   (CURVE_STATE_BLOCK_START_Px + 6)
#define CURVE_STATE_OUT_STR_START_Py   (CURVE_STATE_BLOCK_START_Py + 6)
#define CURVE_STATE_CC_CV_STR_START_Px (CURVE_STATE_BLOCK_START_Px + 42)
#define CURVE_STATE_CC_CV_STR_START_Py (CURVE_STATE_BLOCK_START_Py + 4)
#define CURVE_STATE_DegC_STR_START_Px  (CURVE_STATE_BLOCK_START_Px + 15)
#define CURVE_STATE_DegC_STR_START_Py  (CURVE_STATE_BLOCK_START_Py + 30)
#define CURVE_STATE_TMP_ICON_STR_START_Px  (CURVE_STATE_BLOCK_START_Px + 1)
#define CURVE_STATE_TMP_ICON_STR_START_Py  (CURVE_STATE_BLOCK_START_Py + 32)
/******** */
/******************************************************************************** */
typedef struct point_t{
    mo_u16 x;
    mo_u16 y;
}PointT;

typedef struct table_infor{
    mo_u16 row_num;
    mo_u16 column_num;
    mo_u16 row_distance;
    mo_u16 column_distance;
}TableInforT;

typedef struct vol_scale_infor_{
    mo_u32 vol_dis_scale; /*Unit is mV*/
    char *p_Vunit_str;
}VolScaleInforT;

typedef struct cur_scale_infor_{
    mo_u32 curr_dis_scale;
    char *p_Cunit_str;
    mo_u32 curr_actual_scale;/*Unit is uA*/
}CurScaleInforT;

typedef struct usr_display_task
{
    u16 rec_fill_color;
    char *txt;
    u8 font_size;
    u16 txt_x;
    u16 txt_y;
    u16 txt_color;
}REC_STYLE_T;
typedef enum c_v_dis_type{
    CV_DIS_NONE=0,
    CV_DIS_EN,
    CV_DIS_DISABLE,
    CV_DIS_MAX___
}CV_dis_t;
const mo_task get_usr_display_task(void);
void usr_display_task_init(void);

void to_sync_all_cfg_to_app(mo_u8 in_req_vol, mo_u8 octl, mo_u32 out_cfg);
void display_monitor_dat_handle(MonitorDatsT dats);
void display_draw_calabration_ui(void);

#ifdef __cplusplus
}
#endif

#endif //USR_DESPLAY_TASK__H_H


